var express = require('express');
var router = express.Router();
var {  userModel,stylistModel } = require('../model/model');
/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

router.post('/login',async (req,res)=>{
  const {uname,pwd}=req.body
  console.log(uname,pwd);
  
  const data=await userModel.findOne({uname,pwd})
  const user=await stylistModel.findOne({uname,pwd})
  if(data){
    res.send({code:200,msg:'登录成功',data})
  }else if(user){
    res.send({code:200,msg:'登录成功',data:user})

  }else{
    res.send({code:400,msg:'登录失败'})
  }
})
module.exports = router;
